﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace Htss.Platform.WebApi
{
    public class InputCheck
    {
        /// <summary>
        /// 正则验证
        /// </summary>
        /// <param name="inputText"></param>
        /// <param name="rValue"></param>
        /// <returns></returns>
        public bool IsRegex(string inputText,string rValue)
        {
            if (inputText.Trim() != "")
            {
                Regex r = new Regex(rValue);
                return r.Match(inputText.Trim()).Success;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 两个值比较
        /// </summary>
        /// <param name="inputText"></param>
        /// <param name="tmpText"></param>
        /// <returns></returns>
        public bool IsCompare(string inputText, string tmpText)
        {
            if (inputText.Trim() != "")
            {
                return inputText.Trim() == tmpText.Trim() ? true : false;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 字符长度范围
        /// </summary>
        /// <param name="inputText"></param>
        /// <param name="minLength"></param>
        /// <param name="maxLength"></param>
        /// <returns></returns>
        public bool IsLengthRange(string inputText,int minLength,int maxLength)
        {
            if (inputText.Trim() != "")
            {
                if (inputText.Trim().Length >= minLength && inputText.Trim().Length <= maxLength)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 空值
        /// </summary>
        /// <param name="inputText"></param>
        /// <returns></returns>
        public bool IsNull(string inputText)
        {
            return inputText != null && inputText.Trim() != "" ? true : false;
        }
    }
}
